/* ftp.h */
#pragma once
#include <stdint.h>
#include <stddef.h>

// FTP Standard Commands
#define FTP_CMD_USER    "USER"
#define FTP_CMD_PASS    "PASS"
#define FTP_CMD_CWD     "CWD"
#define FTP_CMD_CDUP    "CDUP"
#define FTP_CMD_PWD     "PWD"
#define FTP_CMD_LIST    "LIST"
#define FTP_CMD_MKD     "MKD"
#define FTP_CMD_RMD     "RMD"
#define FTP_CMD_STOR    "STOR"
#define FTP_CMD_RETR    "RETR"
#define FTP_CMD_DELE    "DELE"
#define FTP_CMD_QUIT    "QUIT"
#define FTP_CMD_PASV    "PASV"
#define FTP_CMD_TYPE    "TYPE"

// FTP Response Codes 
#define FTP_RESPONSE_READY           220
#define FTP_RESPONSE_OK              200
#define FTP_RESPONSE_USER_LOGGED_IN  230
#define FTP_RESPONSE_NEED_PASSWORD   331
#define FTP_RESPONSE_PWD_REPLY       257
#define FTP_RESPONSE_PASV_SUCCESS    227
#define FTP_RESPONSE_TRANSFER_START  150
#define FTP_RESPONSE_FILE_ACTION_OK  250
#define FTP_RESPONSE_FILE_NOT_FOUND  550
#define FTP_RESPONSE_BAD_CMD         500

#define FTP_MAX_CMD_LEN      512
#define FTP_MAX_RESPONSE     4096

// FTP Control Connection Functions 
int ftp_send_command(int sockfd, const char* command, const char* arg);
int ftp_read_response(int sockfd, char* response, size_t max_len);
int ftp_parse_pasv(const char* response, char* ip, int* port);
int ftp_data_connect(const char* ip, int port);

// Helper Functions 
int ftp_login(int ctrl_fd, const char* user, const char* pass);
int ftp_set_binary_mode(int ctrl_fd);
